//
//  NSFileManager+SMC.m
//  SMCKit
//
//  Created by Ren JianSheng on 11-11-15.
//  Copyright (c) 2011年 3gtv.net. All rights reserved.
//

#import "NSFileManager+QL.h"

@implementation NSFileManager (QL)

+(NSString *)ql_readTextWithWebkitPath:(NSString *)path
{
    return @"";
}

- (BOOL)ql_createDirectory:(NSString *)path {
    BOOL result = YES;
    if (![self fileExistsAtPath:path]) {
        NSError *error;
        result = [self createDirectoryAtPath:path 
                      withIntermediateDirectories:YES 
                                       attributes:nil 
                                            error:&error];
        if (!result) {
            NSLog(@"%@",[error localizedDescription]);
        }
    }
    return result;
}

- (BOOL)ql_deleteFile:(NSString *)filePath {
    BOOL result = YES;
    if ([self fileExistsAtPath:filePath]) {
        NSError *error;
        result = [self removeItemAtPath:filePath error:&error];
        if (!result) {
            NSLog(@"%@",[error localizedDescription]);
        }
    }
    return result;
}

- (void)ql_viewCurrentPathDirs:(NSString *)path
{
//    NSString *curPath;  
    NSDirectoryEnumerator *dirEnum;  
//    NSArray *dirArray;  
    //获取当前的工作目录的路径  
//    path = [self currentDirectoryPath];  
    
    //遍历这个目录的第一种方法：（深度遍历，会递归枚举它的内容）  
    dirEnum = [self enumeratorAtPath:path];  
    
    NSLog(@"1.Contents of %@:",path);  
    while ((path = [dirEnum nextObject]) != nil)  
    {  
        NSLog(@"%@",path);  
    }  
//    
//    //遍历目录的另一种方法：（不递归枚举文件夹种的内容）  
//    dirArray = [self directoryContentsAtPath:[fm currentDirectoryPath]];  
//    NSLog(@"2.Contents using directoryContentsAtPath：");  
//    
//    for(path in dirArray)  
//        NSLog(@"%@",path);   
}



@end
